## Kucik and Reinhardt 2008 IO

library(foreign)
library(Amelia)

## Load original dataset
kr2008 <- read.dta("KR2008 IO Rep Data.dta")
head(kr2008)
dim(kr2008)

## Convert character to numeric
kr2008$gattwto <- as.numeric(kr2008$gattwto)

## Drop ID and other index vars
kr2008$st1 <- kr2008$gsp <-NULL

## Drop derived dummy vars
kr2008$aduserconsist <- kr2008$START <- NULL

## Drop constituent components
kr2008$gatt <- kr2008$wto <- NULL
 
## Drop calculated parameters
kr2008$zaduser <- kr2008$ztargeted <- kr2008$waduser <- kr2008$wtargeted <- kr2008$yearsnoadlaw_1 <- kr2008$yearsnoadlaw_1 <- kr2008$yearsnoadlaw_2 <- kr2008$yearsnoadlaw_3 <- kr2008$yearsnogatt_1 <- kr2008$yearsnogatt_2 <- kr2008$yearsnogatt_3 <- kr2008$boundavediff <- kr2008$FACTOR_1 <-kr2008$FACTOR_2 <-kr2008$FACTORB_1 <-kr2008$FACTORC_1 <-kr2008$BQl1 <-kr2008$FACTORD_1 <-kr2008$gese96 <-kr2008$ge96 <-kr2008$gefilll1 <-kr2008$Model1 <-kr2008$Model2 <- kr2008$Model3 <-kr2008$Model4 <-kr2008$Model5 <-kr2008$ModelANY <- kr2008$FACTB1obs <-kr2008$FACTC1obs <-kr2008$FACTD1obs <- kr2008$FACT1obs <- kr2008$FACT2obs <- NULL

which( colnames(kr2008)=="_____________" )
kr2008 <- kr2008[, -c(143)]
head(kr2008)

## How many variables? 174: reduction necessary
dim(kr2008)

## Which variables are in analysis and have missing data?
sum(is.na(kr2008 $gattwto))/nrow(kr2008)*100
sum(is.na(kr2008 $adlaw))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $lnpercap))/nrow(kr2008)*100
sum(is.na(kr2008 $polity1))/nrow(kr2008)*100
sum(is.na(kr2008 $lngdp))/nrow(kr2008)*100
sum(is.na(kr2008 $lnimports))/nrow(kr2008)*100
sum(is.na(kr2008 $reggattwto2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $gattwtol1))/nrow(kr2008)*100 
sum(is.na(kr2008 $gwl1_adlaw))/nrow(kr2008)*100 
sum(is.na(kr2008 $gwl1_lnpercap))/nrow(kr2008)*100 
sum(is.na(kr2008 $gwl1_polity1))/nrow(kr2008)*100
sum(is.na(kr2008 $gwl1_lngdp))/nrow(kr2008)*100
sum(is.na(kr2008 $gwl1_lnimports))/nrow(kr2008)*100
sum(is.na(kr2008 $gwl1_reggattwto2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $adtarget))/nrow(kr2008)*100
sum(is.na(kr2008 $regadlaw2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $adlawl1))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_gattwto))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_lnpercap))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_polity1))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_lngdp))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_lnimports))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_adtarget))/nrow(kr2008)*100
sum(is.na(kr2008 $adl1_regadlaw2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $year))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $firstyear))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $BOUNDAVE))/nrow(kr2008)*100
sum(is.na(kr2008 $regBOUNDAVE2))/nrow(kr2008)*100
sum(is.na(kr2008 $gefill))/nrow(kr2008)*100
sum(is.na(kr2008 $yearsnogatt))/nrow(kr2008)*100
sum(is.na(kr2008 $yearsnogatt_1))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $yearsnogatt_2))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $yearsnogatt_3))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $treatreg))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $simpduties))/nrow(kr2008)*100
sum(is.na(kr2008 $eumembership))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $regsimpduties2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $tariffNEWl0))/nrow(kr2008)*100
sum(is.na(kr2008 $regtariffNEW2l1))/nrow(kr2008)*100
sum(is.na(kr2008 $stnam1))/nrow(kr2008)*100 ## N
sum(is.na(kr2008 $year))/nrow(kr2008)*100 ## N

analysis <- as.data.frame(cbind(kr2008$gattwto, kr2008$lnpercap, kr2008$polity1, kr2008$lngdp, kr2008$lnimports, kr2008$reggattwto2l1, kr2008$gattwtol1, kr2008$gwl1_adlaw, kr2008$gwl1_lnpercap, kr2008$gwl1_polity1, kr2008$gwl1_lngdp, kr2008$gwl1_lnimports, kr2008$gwl1_reggattwto2l1, kr2008$adtarget, kr2008$regadlaw2l1, kr2008$adlawl1, kr2008$adl1_gattwto, kr2008$adl1_lnpercap, kr2008$adl1_polity1, kr2008$adl1_lngdp, kr2008$adl1_lnimports, kr2008$adl1_adtarget, kr2008$adl1_regadlaw2l1, kr2008$BOUNDAVE, kr2008$regBOUNDAVE2, kr2008$gefill, kr2008$yearsnogatt, kr2008$simpduties, kr2008$regsimpduties2l1, kr2008$tariffNEWl0, kr2008$regtariffNEW2l1))

missing <-as.data.frame(cbind(as.integer(complete.cases(kr2008$gattwto)), as.integer(complete.cases(kr2008$lnpercap)), as.integer(complete.cases(kr2008$polity1)), as.integer(complete.cases(kr2008$lngdp)), as.integer(complete.cases(kr2008$lnimports)), as.integer(complete.cases(kr2008$reggattwto2l1)), as.integer(complete.cases(kr2008$gattwtol1)), as.integer(complete.cases(kr2008$gwl1_adlaw)), as.integer(complete.cases(kr2008$gwl1_lnpercap)), as.integer(complete.cases(kr2008$gwl1_polity1)), as.integer(complete.cases(kr2008$gwl1_lngdp)), as.integer(complete.cases(kr2008$gwl1_lnimports)), as.integer(complete.cases(kr2008$gwl1_reggattwto2l1)), as.integer(complete.cases(kr2008$adtarget)), as.integer(complete.cases(kr2008$regadlaw2l1)), as.integer(complete.cases(kr2008$adlawl1)), as.integer(complete.cases(kr2008$adl1_gattwto)), as.integer(complete.cases(kr2008$adl1_lnpercap)), as.integer(complete.cases(kr2008$adl1_polity1)), as.integer(complete.cases(kr2008$adl1_lngdp)), as.integer(complete.cases(kr2008$adl1_lnimports)), as.integer(complete.cases(kr2008$adl1_adtarget)), as.integer(complete.cases(kr2008$adl1_regadlaw2l1)), as.integer(complete.cases(kr2008$BOUNDAVE)), as.integer(complete.cases(kr2008$regBOUNDAVE2)), as.integer(complete.cases(kr2008$gefill)), as.integer(complete.cases(kr2008$yearsnogatt)), as.integer(complete.cases(kr2008$simpduties)), as.integer(complete.cases(kr2008$regsimpduties2l1)), as.integer(complete.cases(kr2008$tariffNEWl0)), as.integer(complete.cases(kr2008$regtariffNEW2l1))))

dim(analysis)
dim(missing)
apply(missing, 2, sd)

## Remove analysis variables
## kr2008$gattwto <- kr2008$lnpercap <-kr2008$polity1<- kr2008$lngdp<- kr2008$lnimports <- kr2008$reggattwto2l1 <- kr2008$gattwtol1 <- kr2008$gwl1_adlaw <- kr2008$gwl1_lnpercap <- kr2008$gwl1_polity1 <- kr2008$gwl1_lngdp <- kr2008$gwl1_lnimports <- kr2008$gwl1_reggattwto2l1 <- kr2008$adtarget <- kr2008$regadlaw2l1 <- kr2008$adlawl1 <- kr2008$adl1_gattwto <- kr2008$adl1_lnpercap <- kr2008$adl1_polity1 <- kr2008$adl1_lngdp <- kr2008$adl1_lnimports <- kr2008$adl1_adtarget <- kr2008$adl1_regadlaw2l1 <- kr2008$BOUNDAVE <- kr2008$regBOUNDAVE2 <- kr2008$gefill <- kr2008$yearsnogatt <- kr2008$simpduties <- kr2008$regsimpduties2l1 <- kr2008$tariffNEWl0 <- kr2008$regtariffNEW2l1 <- NULL
## head(kr2008)
## var(kr2008)

## Check correlations and missing values
round(cor(kr2008$aduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$aduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$aduser ))/nrow(kr2008)*100
## Y

round(cor(kr2008$gdp , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gdp , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gdp ))/nrow(kr2008)*100
## N
kr2008$gdp  <- NULL

round(cor(kr2008$percap , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$percap , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$percap ))/nrow(kr2008)*100
## N
kr2008$percap  <- NULL

round(cor(kr2008$imports , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$imports , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$imports ))/nrow(kr2008)*100
## N
kr2008$imports  <- NULL

round(cor(kr2008$growth , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$growth , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$growth ))/nrow(kr2008)*100
## N
kr2008$growth  <- NULL

round(cor(kr2008$totalduties , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$totalduties , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$totalduties ))/nrow(kr2008)*100
## N
kr2008$totalduties  <- NULL

round(cor(kr2008$tariff , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tariff , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tariff ))/nrow(kr2008)*100
## N
kr2008$tariff  <- NULL

round(cor(kr2008$tarworldbank , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tarworldbank , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tarworldbank ))/nrow(kr2008)*100
## N
kr2008$tarworldbank  <- NULL

round(cor(kr2008$tartrains , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tartrains , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tartrains ))/nrow(kr2008)*100
## N
kr2008$tartrains  <- NULL

round(cor(kr2008$auxtarmeas1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$auxtarmeas1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$auxtarmeas1 ))/nrow(kr2008)*100
## N
kr2008$auxtarmeas1  <- NULL

round(cor(kr2008$auxtarmeas2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$auxtarmeas2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$auxtarmeas2 ))/nrow(kr2008)*100
## N
kr2008$auxtarmeas2  <- NULL

round(cor(kr2008$auxtarmeas3 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$auxtarmeas3 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$auxtarmeas3 ))/nrow(kr2008)*100
## N
kr2008$auxtarmeas3  <- NULL

round(cor(kr2008$boundper , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$boundper , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$boundper ))/nrow(kr2008)*100
## N
kr2008$boundper  <- NULL

round(cor(kr2008$boundave , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$boundave , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$boundave ))/nrow(kr2008)*100
## N
kr2008$boundave  <- NULL

round(cor(kr2008$zmeasure , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$zmeasure , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$zmeasure ))/nrow(kr2008)*100
## N
kr2008$zmeasure  <- NULL

round(cor(kr2008$zinvest , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$zinvest , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$zinvest ))/nrow(kr2008)*100
## N
kr2008$zinvest  <- NULL

round(cor(kr2008$zinvestag , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$zinvestag , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$zinvestag ))/nrow(kr2008)*100
## N
kr2008$zinvestag  <- NULL

round(cor(kr2008$zmeasag , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$zmeasag , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$zmeasag ))/nrow(kr2008)*100
## N
kr2008$zmeasag  <- NULL

round(cor(kr2008$winvestigations , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$winvestigations , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$winvestigations ))/nrow(kr2008)*100
## N
kr2008$winvestigations  <- NULL

round(cor(kr2008$wmeasures , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$wmeasures , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$wmeasures ))/nrow(kr2008)*100
## N
kr2008$wmeasures  <- NULL

round(cor(kr2008$wtargetedm , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$wtargetedm , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$wtargetedm ))/nrow(kr2008)*100
## N
kr2008$wtargetedm  <- NULL

round(cor(kr2008$wtargetedi , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$wtargetedi , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$wtargetedi ))/nrow(kr2008)*100
## N
kr2008$wtargetedi  <- NULL

round(cor(kr2008$tradepartner , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tradepartner , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tradepartner ))/nrow(kr2008)*100
## N
kr2008$tradepartner  <- NULL

round(cor(kr2008$trpartgattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trpartgattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trpartgattwto ))/nrow(kr2008)*100
## N
kr2008$trpartgattwto  <- NULL

round(cor(kr2008$trpartadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trpartadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trpartadlaw ))/nrow(kr2008)*100
## N
kr2008$trpartadlaw  <- NULL

round(cor(kr2008$trpartaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trpartaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trpartaduser ))/nrow(kr2008)*100
## N
kr2008$trpartaduser  <- NULL

round(cor(kr2008$trpartadtarg , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trpartadtarg , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trpartadtarg ))/nrow(kr2008)*100
## N
kr2008$trpartadtarg  <- NULL

round(cor(kr2008$trpartduties , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trpartduties , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trpartduties ))/nrow(kr2008)*100
## N
kr2008$trpartduties  <- NULL

round(cor(kr2008$trparttariff , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$trparttariff , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$trparttariff ))/nrow(kr2008)*100
## N
kr2008$trparttariff  <- NULL

round(cor(kr2008$contgattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$contgattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$contgattwto ))/nrow(kr2008)*100
## N
kr2008$contgattwto  <- NULL

round(cor(kr2008$contadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$contadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$contadlaw ))/nrow(kr2008)*100
## N
kr2008$contadlaw  <- NULL

round(cor(kr2008$contaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$contaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$contaduser ))/nrow(kr2008)*100
## N
kr2008$contaduser  <- NULL

round(cor(kr2008$contadtarg , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$contadtarg , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$contadtarg ))/nrow(kr2008)*100
## N
kr2008$contadtarg  <- NULL

round(cor(kr2008$contduties , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$contduties , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$contduties ))/nrow(kr2008)*100
## N
kr2008$contduties  <- NULL

round(cor(kr2008$conttariff , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$conttariff , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$conttariff ))/nrow(kr2008)*100
## N
kr2008$conttariff  <- NULL

round(cor(kr2008$topten , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$topten , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$topten ))/nrow(kr2008)*100
## N
kr2008$topten  <- NULL

round(cor(kr2008$top10gattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10gattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10gattwto ))/nrow(kr2008)*100
## N
kr2008$top10gattwto  <- NULL

round(cor(kr2008$top10adlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10adlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10adlaw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$top10aduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10aduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10aduser ))/nrow(kr2008)*100
## Y

round(cor(kr2008$top10adtarg , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10adtarg , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10adtarg ))/nrow(kr2008)*100
## N
kr2008$top10adtarg  <- NULL

round(cor(kr2008$top10duties , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10duties , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10duties ))/nrow(kr2008)*100
## N
kr2008$top10duties  <- NULL

round(cor(kr2008$top10tariff , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$top10tariff , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$top10tariff ))/nrow(kr2008)*100
## N
kr2008$top10tariff  <- NULL

round(cor(kr2008$reggattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$reggattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$reggattwto ))/nrow(kr2008)*100
## Y

round(cor(kr2008$regadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regadlaw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$regaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regaduser ))/nrow(kr2008)*100
## N
kr2008$regaduser  <- NULL

round(cor(kr2008$regadtarg , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regadtarg , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regadtarg ))/nrow(kr2008)*100
## N
kr2008$regadtarg  <- NULL

round(cor(kr2008$regduties , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regduties , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regduties ))/nrow(kr2008)*100
## N
kr2008$regduties  <- NULL

round(cor(kr2008$regtariff , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regtariff , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regtariff ))/nrow(kr2008)*100
## N
kr2008$regtariff  <- NULL

round(cor(kr2008$adlawlag , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adlawlag , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adlawlag ))/nrow(kr2008)*100
## Y

round(cor(kr2008$dumpsum , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$dumpsum , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$dumpsum ))/nrow(kr2008)*100
## Y

round(cor(kr2008$becomemember , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$becomemember , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$becomemember ))/nrow(kr2008)*100
## N
kr2008$becomemember  <- NULL

round(cor(kr2008$adoptedad , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adoptedad , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adoptedad ))/nrow(kr2008)*100
## N
kr2008$adoptedad  <- NULL

round(cor(kr2008$usedadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$usedadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$usedadlaw ))/nrow(kr2008)*100
## N
kr2008$usedadlaw  <- NULL

round(cor(kr2008$aduserlag , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$aduserlag , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$aduserlag ))/nrow(kr2008)*100
## Y

round(cor(kr2008$yearsingatt , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearsingatt , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearsingatt ))/nrow(kr2008)*100
## Y

round(cor(kr2008$yearsaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearsaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearsaduser ))/nrow(kr2008)*100
## N
kr2008$yearsaduser  <- NULL

round(cor(kr2008$yearsnotaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearsnotaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearsnotaduser ))/nrow(kr2008)*100
## N
kr2008$yearsnotaduser  <- NULL

round(cor(kr2008$yearsadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearsadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearsadlaw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$yearsnoadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearsnoadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearsnoadlaw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$START0gw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$START0gw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$START0gw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$START00adlawgw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$START00adlawgw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$START00adlawgw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$tariffl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tariffl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tariffl1 ))/nrow(kr2008)*100
## N
kr2008$tariffl1  <- NULL

round(cor(kr2008$regdutiesl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regdutiesl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regdutiesl1 ))/nrow(kr2008)*100
## N
kr2008$regdutiesl1  <- NULL

round(cor(kr2008$regtariffl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regtariffl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regtariffl1 ))/nrow(kr2008)*100
## N
kr2008$regtariffl1  <- NULL

round(cor(kr2008$gwl1_reggattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gwl1_reggattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gwl1_reggattwto ))/nrow(kr2008)*100
## Y

round(cor(kr2008$adl1_growth , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adl1_growth , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adl1_growth ))/nrow(kr2008)*100
## N
kr2008$adl1_growth  <- NULL

round(cor(kr2008$adl1_regadlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adl1_regadlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adl1_regadlaw ))/nrow(kr2008)*100
## Y

round(cor(kr2008$lnpercap_adlaw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$lnpercap_adlaw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$lnpercap_adlaw ))/nrow(kr2008)*100
## N
kr2008$lnpercap_adlaw  <- NULL

round(cor(kr2008$gwl1_lnpcadl , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gwl1_lnpcadl , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gwl1_lnpcadl ))/nrow(kr2008)*100
## N
kr2008$gwl1_lnpcadl  <- NULL

round(cor(kr2008$lnpercap_gw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$lnpercap_gw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$lnpercap_gw ))/nrow(kr2008)*100
## N
kr2008$lnpercap_gw  <- NULL

round(cor(kr2008$adl1_lnpercap_gw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adl1_lnpercap_gw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adl1_lnpercap_gw ))/nrow(kr2008)*100
## N
kr2008$adl1_lnpercap_gw  <- NULL

round(cor(kr2008$adl1_simpdutiesl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adl1_simpdutiesl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adl1_simpdutiesl1 ))/nrow(kr2008)*100
## N adl1_simpdutiesl1 kr2008$aduser  <- NULL

round(cor(kr2008$aduserl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$aduserl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$aduserl1 ))/nrow(kr2008)*100
## Y

round(cor(kr2008$adul1_gattwto , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_gattwto , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_gattwto ))/nrow(kr2008)*100
## N
kr2008$adul1_gattwto  <- NULL

round(cor(kr2008$adul1_polity1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_polity1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_polity1 ))/nrow(kr2008)*100
## N
kr2008$adul1_polity1  <- NULL

round(cor(kr2008$adul1_lngdp , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_lngdp , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_lngdp ))/nrow(kr2008)*100
## N
kr2008$adul1_lngdp  <- NULL

round(cor(kr2008$adul1_lnpercap , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_lnpercap , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_lnpercap ))/nrow(kr2008)*100
## N
kr2008$adul1_lnpercap  <- NULL

round(cor(kr2008$adul1_growth , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_growth , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_growth ))/nrow(kr2008)*100
## N
kr2008$adul1_growth  <- NULL

round(cor(kr2008$adul1_lnimports , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_lnimports , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_lnimports ))/nrow(kr2008)*100
## N
kr2008$adul1_lnimports  <- NULL

round(cor(kr2008$adul1_adtarget , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_adtarget , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_adtarget ))/nrow(kr2008)*100
## N
kr2008$adul1_adtarget  <- NULL

round(cor(kr2008$adul1_regaduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_regaduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_regaduser ))/nrow(kr2008)*100
## N
kr2008$adul1_regaduser  <- NULL

round(cor(kr2008$gwl1_aduser , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gwl1_aduser , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gwl1_aduser ))/nrow(kr2008)*100
## N
kr2008$gwl1_aduser  <- NULL

round(cor(kr2008$importsraw , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$importsraw , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$importsraw ))/nrow(kr2008)*100
## N
kr2008$importsraw  <- NULL

round(cor(kr2008$invest , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$invest , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$invest ))/nrow(kr2008)*100
## N
kr2008$invest  <- NULL

round(cor(kr2008$measures , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$measures , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$measures ))/nrow(kr2008)*100
## N
kr2008$measures  <- NULL

round(cor(kr2008$investimp , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$investimp , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$investimp ))/nrow(kr2008)*100
## N
kr2008$investimp  <- NULL

round(cor(kr2008$measuresimp , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$measuresimp , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$measuresimp ))/nrow(kr2008)*100
## N
kr2008$measuresimp  <- NULL

round(cor(kr2008$region , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$region , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$region ))/nrow(kr2008)*100
## N
kr2008$region  <- NULL

round(cor(kr2008$regpartners , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regpartners , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regpartners ))/nrow(kr2008)*100
## N
kr2008$regpartners  <- NULL

round(cor(kr2008$regaduser2l1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regaduser2l1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regaduser2l1 ))/nrow(kr2008)*100
## N
kr2008$regaduser2l1  <- NULL

round(cor(kr2008$reggattwto2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$reggattwto2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$reggattwto2 ))/nrow(kr2008)*100
## Y

round(cor(kr2008$regadlaw2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regadlaw2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regadlaw2 ))/nrow(kr2008)*100
## Y

round(cor(kr2008$regaduser2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regaduser2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regaduser2 ))/nrow(kr2008)*100
## N
kr2008$regaduser2  <- NULL

round(cor(kr2008$regsimpduties2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regsimpduties2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regsimpduties2 ))/nrow(kr2008)*100
## N
kr2008$regsimpduties2  <- NULL

round(cor(kr2008$regtariff2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regtariff2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regtariff2 ))/nrow(kr2008)*100
## N
kr2008$regtariff2  <- NULL

round(cor(kr2008$reginvestimp2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$reginvestimp2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$reginvestimp2 ))/nrow(kr2008)*100
## N
kr2008$reginvestimp2  <- NULL

round(cor(kr2008$regmeasuresimp2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regmeasuresimp2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regmeasuresimp2 ))/nrow(kr2008)*100
## N
kr2008$regmeasuresimp2  <- NULL

round(cor(kr2008$regtariff2l1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regtariff2l1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regtariff2l1 ))/nrow(kr2008)*100
## N
kr2008$regtariff2l1  <- NULL

round(cor(kr2008$reginvestimp2l1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$reginvestimp2l1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$reginvestimp2l1 ))/nrow(kr2008)*100
## N
kr2008$reginvestimp2l1  <- NULL

round(cor(kr2008$regmeasuresimp2l1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regmeasuresimp2l1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regmeasuresimp2l1 ))/nrow(kr2008)*100
## N
kr2008$regmeasuresimp2l1  <- NULL

round(cor(kr2008$adul1_regaduser2l1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adul1_regaduser2l1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adul1_regaduser2l1 ))/nrow(kr2008)*100
## N
kr2008$adul1_regaduser2l1  <- NULL

round(cor(kr2008$BOUNDPER , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$BOUNDPER , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$BOUNDPER ))/nrow(kr2008)*100
## N
kr2008$BOUNDPER  <- NULL

round(cor(kr2008$regBOUNDPER2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$regBOUNDPER2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$regBOUNDPER2 ))/nrow(kr2008)*100
## Y

round(cor(kr2008$polity , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$polity , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$polity ))/nrow(kr2008)*100
## N
kr2008$polity  <- NULL

round(cor(kr2008$polityBAD , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$polityBAD , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$polityBAD ))/nrow(kr2008)*100
## N
kr2008$polityBAD  <- NULL

round(cor(kr2008$propUSADonST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$propUSADonST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$propUSADonST2 ))/nrow(kr2008)*100
## N
kr2008$propUSADonST2  <- NULL

round(cor(kr2008$propUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$propUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$propUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$propUSADfiledvsST2  <- NULL

round(cor(kr2008$propimpsUSADonST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$propimpsUSADonST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$propimpsUSADonST2 ))/nrow(kr2008)*100
## N
kr2008$propimpsUSADonST2  <- NULL

round(cor(kr2008$propimpsUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$propimpsUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$propimpsUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$propimpsUSADfiledvsST2  <- NULL

round(cor(kr2008$timesUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$timesUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$timesUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$timesUSADfiledvsST2  <- NULL

round(cor(kr2008$timesUSADaffonST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$timesUSADaffonST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$timesUSADaffonST2 ))/nrow(kr2008)*100
## N
kr2008$timesUSADaffonST2  <- NULL

round(cor(kr2008$impsUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$impsUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$impsUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$impsUSADfiledvsST2  <- NULL

round(cor(kr2008$impsUSADaffonST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$impsUSADaffonST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$impsUSADaffonST2 ))/nrow(kr2008)*100
## N
kr2008$impsUSADaffonST2  <- NULL

round(cor(kr2008$adl1_propUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$adl1_propUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$adl1_propUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$adl1_propUSADfiledvsST2  <- NULL

round(cor(kr2008$lnimpsUSADfiledvsST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$lnimpsUSADfiledvsST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$lnimpsUSADfiledvsST2 ))/nrow(kr2008)*100
## N
kr2008$lnimpsUSADfiledvsST2  <- NULL

round(cor(kr2008$lnimpsUSADaffonST2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$lnimpsUSADaffonST2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$lnimpsUSADaffonST2 ))/nrow(kr2008)*100
## N
kr2008$lnimpsUSADaffonST2  <- NULL

round(cor(kr2008$gspl1c , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gspl1c , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gspl1c ))/nrow(kr2008)*100
## N
kr2008$gspl1c  <- NULL

round(cor(kr2008$gspfracboth , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gspfracboth , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gspfracboth ))/nrow(kr2008)*100
## N
kr2008$gspfracboth  <- NULL

round(cor(kr2008$totimpsl0 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$totimpsl0 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$totimpsl0 ))/nrow(kr2008)*100
## N
kr2008$totimpsl0  <- NULL

round(cor(kr2008$prefimpsl0 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$prefimpsl0 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$prefimpsl0 ))/nrow(kr2008)*100
## N
kr2008$prefimpsl0  <- NULL

round(cor(kr2008$prefpctl0 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$prefpctl0 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$prefpctl0 ))/nrow(kr2008)*100
## N
kr2008$prefpctl0  <- NULL

round(cor(kr2008$totimpsl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$totimpsl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$totimpsl1 ))/nrow(kr2008)*100
## N
kr2008$totimpsl1  <- NULL

round(cor(kr2008$prefimpsl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$prefimpsl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$prefimpsl1 ))/nrow(kr2008)*100
## N
kr2008$prefimpsl1  <- NULL

round(cor(kr2008$prefpctl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$prefpctl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$prefpctl1 ))/nrow(kr2008)*100
## N
kr2008$prefpctl1  <- NULL

round(cor(kr2008$tariffWBl0 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tariffWBl0 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tariffWBl0 ))/nrow(kr2008)*100
## N
kr2008$tariffWBl0  <- NULL

round(cor(kr2008$tariffWBl1 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tariffWBl1 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tariffWBl1 ))/nrow(kr2008)*100
## N
kr2008$tariffWBl1  <- NULL

round(cor(kr2008$yearWB2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$yearWB2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$yearWB2 ))/nrow(kr2008)*100
## N
kr2008$yearWB2  <- NULL

round(cor(kr2008$tariffWB2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$tariffWB2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$tariffWB2 ))/nrow(kr2008)*100
## Y

round(cor(kr2008$boundrateWB2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$boundrateWB2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$boundrateWB2 ))/nrow(kr2008)*100
## N
kr2008$boundrateWB2  <- NULL

round(cor(kr2008$boundperWB2 , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$boundperWB2 , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$boundperWB2 ))/nrow(kr2008)*100
## N
kr2008$boundperWB2  <- NULL

round(cor(kr2008$BQ , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$BQ , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$BQ ))/nrow(kr2008)*100
## N
kr2008$BQ  <- NULL

round(cor(kr2008$gese , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$gese , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$gese ))/nrow(kr2008)*100
## N
kr2008$gese  <- NULL

round(cor(kr2008$ge , analysis, use = "pairwise.complete.obs"), 2)
round(cor(kr2008$ge , missing, use = "pairwise.complete.obs"), 2)
sum(is.na(kr2008$ge ))/nrow(kr2008)*100
## N
kr2008$ge  <- NULL

## Imputation
dim(kr2008)

## What is average percentage of missing data?
NAs <- function(x) {
    as.vector(apply(x, 2, function(x) length(which(is.na(x)))))
    }
NAs(kr2008)
mean(NAs(kr2008)/nrow(kr2008))*100

## Thus: 25 imputations

## There are already lags for tariffNEWl0, gattwto, adlaw, and simpduties
set.seed(02138)
kr2008.out <- amelia(kr2008, m = 25, ts = "year", cs = "stnam1", polytime = 3, lags = c("BOUNDAVE"), empri = 0.01*nrow(kr2008))

write.amelia(obj=kr2008.out, file.stem = "KR2008 IO Imp Data.dta", format = "dta", separate = FALSE)
